<?php

namespace App\Controller;


use App\Request\LoginRequest;
use App\serve\UserServe;
use Hyperf\Contract\Arrayable;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\PostMapping;
use Qbhy\HyperfAuth\Guard\JwtGuard;

#[Controller]
class LoginController extends AbstractController
{
    /**
     * @var JwtGuard
     */
    #[Inject]
    protected JwtGuard $jwtGuard;


    #[Inject]
    public UserServe $userServe;


    /**
     * @param LoginRequest $request
     * @return \Psr\Http\Message\MessageInterface|\Psr\Http\Message\ResponseInterface
     */
    #[PostMapping('login')]
    public function login(LoginRequest $request)
    {
        // 验证参数

        $this->logger->info('请求参数',$request->validated());

        $user =  $this->userServe->user(1);


        return $this->success(['token'=>$this->jwtGuard->login($user)]);

    }



}